package homework.day09; 
 /*
 @Time: 2022/7/21 20:31
 @Author:GShuai
 @File:Test04.class
 @Software:IntelliJ IDEA
*/

import java.util.*;

/**
 * 将整数1-100存入一个List集合中并输出
 * 之后将集合中40-60的元素翻转后并输出
 */
public class Test04 {
    public static void main(String[] args) {
        List<Integer> list = new ArrayList<>();

        Random random = new Random();
//        for(int i =1 ;i<100;i++){   1 -100 <=
        for(int i =1 ;i<=100;i++){
//            list.add(random.nextInt(100+1));
            list.add(i);    //直接添加即可
        }

        System.out.println(list);
        Collections.sort(list);  //升序
        System.out.println(list);

        List<Integer> list1 = list.subList(39, 60);
        Collections.reverse(list1);  //反转
        System.out.println(list1);

    }
}
